/**
 * <copyright>
 *
 * Copyright (c) 2011 Zeligsoft (2009) Limited
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   Zeligsoft (2009) Limited - Initial API and implementation
 *
 * </copyright>
 *
 */
package org.omg.deployment.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;
import org.omg.deployment.DeploymentPackage;
import org.omg.deployment.PlanPropertyMapping;
import org.omg.deployment.PlanSubcomponentPropertyReference;
import org.omg.xmi.impl.XMIImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Plan Property Mapping</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.omg.deployment.impl.PlanPropertyMappingImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.omg.deployment.impl.PlanPropertyMappingImpl#getSource <em>Source</em>}</li>
 *   <li>{@link org.omg.deployment.impl.PlanPropertyMappingImpl#getExternalName <em>External Name</em>}</li>
 *   <li>{@link org.omg.deployment.impl.PlanPropertyMappingImpl#getDelegatesTo <em>Delegates To</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PlanPropertyMappingImpl extends XMIImpl implements
		PlanPropertyMapping {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The default value of the '{@link #getExternalName() <em>External Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExternalName()
	 * @generated
	 * @ordered
	 */
	protected static final String EXTERNAL_NAME_EDEFAULT = null;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PlanPropertyMappingImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DeploymentPackage.eINSTANCE.getPlanPropertyMapping();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return (String) getGroup()
				.get(DeploymentPackage.eINSTANCE.getPlanPropertyMapping_Name(),
						true);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		((FeatureMap.Internal) getGroup()).set(
				DeploymentPackage.eINSTANCE.getPlanPropertyMapping_Name(),
				newName);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<String> getSource() {
		return getGroup().list(
				DeploymentPackage.eINSTANCE.getPlanPropertyMapping_Source());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getExternalName() {
		return (String) getGroup()
				.get(DeploymentPackage.eINSTANCE
						.getPlanPropertyMapping_ExternalName(),
						true);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setExternalName(String newExternalName) {
		((FeatureMap.Internal) getGroup()).set(DeploymentPackage.eINSTANCE
				.getPlanPropertyMapping_ExternalName(), newExternalName);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<PlanSubcomponentPropertyReference> getDelegatesTo() {
		return getGroup().list(
				DeploymentPackage.eINSTANCE
						.getPlanPropertyMapping_DelegatesTo());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__DELEGATES_TO:
			return ((InternalEList<?>) getDelegatesTo()).basicRemove(otherEnd,
					msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__NAME:
			return getName();
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__SOURCE:
			return getSource();
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__EXTERNAL_NAME:
			return getExternalName();
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__DELEGATES_TO:
			return getDelegatesTo();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__NAME:
			setName((String) newValue);
			return;
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__SOURCE:
			getSource().clear();
			getSource().addAll((Collection<? extends String>) newValue);
			return;
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__EXTERNAL_NAME:
			setExternalName((String) newValue);
			return;
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__DELEGATES_TO:
			getDelegatesTo().clear();
			getDelegatesTo()
					.addAll((Collection<? extends PlanSubcomponentPropertyReference>) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__NAME:
			setName(NAME_EDEFAULT);
			return;
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__SOURCE:
			getSource().clear();
			return;
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__EXTERNAL_NAME:
			setExternalName(EXTERNAL_NAME_EDEFAULT);
			return;
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__DELEGATES_TO:
			getDelegatesTo().clear();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__NAME:
			return NAME_EDEFAULT == null ? getName() != null : !NAME_EDEFAULT
					.equals(getName());
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__SOURCE:
			return !getSource().isEmpty();
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__EXTERNAL_NAME:
			return EXTERNAL_NAME_EDEFAULT == null ? getExternalName() != null
					: !EXTERNAL_NAME_EDEFAULT.equals(getExternalName());
		case DeploymentPackage.PLAN_PROPERTY_MAPPING__DELEGATES_TO:
			return !getDelegatesTo().isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //PlanPropertyMappingImpl
